import { getCustomerSelectList } from "@/api/managementCenter/customerManagement";
import { getAllCompanyApi, getUserByPositionApi } from "@/api/managementCenter/departmentPersonnel";
import { getListApi as getAllPaymentApi } from "@/api/configCenter/paymentManagement";
import { getTreeChannelApi } from "@/api/configCenter/warehouseEntryChannel";
import { TreeSelect } from "ant-design-vue";
const SHOW_CHILD = TreeSelect.SHOW_CHILD;
import { reactive } from "vue";

export const searchItemList: Array<SuperSearch.SearchItem> = [
  {
    type: "input",
    label: "关键字",
    keyName: "keyWordsList",
    placeholder: "支持运单号、转单号、FBA单号,支持批量(空格/逗号隔开)"
  },
  {
    type: "input",
    label: "运单号",
    keyName: "waybillNums",
    placeholder: "支持批量(空格/逗号隔开)"
  },
  reactive<SuperSearch.SearchItem>({
    type: "select",
    label: "客户简称",
    keyName: "customerIdList",
    optionsRequest: getCustomerSelectList,
    optReqParams: { isFilterChild: 0 },
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data || [];
      }
    },
    attrs: {
      mode: "multiple"
    },
    optConfig: {
      label: "shortName",
      value: "id"
    },
    options: []
  }),
  {
    type: "dict-select",
    label: "运单类型",
    keyName: "addressTypeList",
    lookupCode: "WAYBILL_TYPE",
    optConfig: {
      label: "name",
      value: "code"
    },
    attrs: {
      mode: "multiple"
    },
    options: []
  },
  reactive<SuperSearch.SearchItem>({
    type: "select",
    label: "业务员",
    keyName: "bizIdList",
    optionsRequest: getUserByPositionApi,
    optReqParams: { position: "4", status: 1, pageNum: 1, pageSize: 9999999, total: 0 },
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data.records || [];
      }
    },
    optConfig: {
      label: "username",
      value: "id"
    },
    attrs: {
      mode: "multiple"
    },
    options: []
  }),
  reactive<SuperSearch.SearchItem>({
    type: "select",
    label: "经营单位",
    keyName: "companyIdList",
    optionsRequest: getAllCompanyApi,
    optReqParams: { status: 1, pageNum: 1, pageSize: 9999999, total: 0 },
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data || [];
      }
    },
    optConfig: {
      label: "name",
      value: "id"
    },
    attrs: {
      mode: "multiple"
    },
    options: []
  }),
  reactive<SuperSearch.SearchItem>({
    type: "cascader",
    label: "渠道",
    keyName: "channelIdList",
    optionsRequest: getTreeChannelApi,
    optReqParams: {},
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data || [];
      }
    },
    optConfig: {
      label: "label",
      value: "value",
      children: "children"
    },
    attrs: {
      multiple: true,
      showCheckedStrategy: SHOW_CHILD
    },
    options: []
  }),
  reactive<SuperSearch.SearchItem>({
    type: "select",
    label: "账期",
    keyName: "accountPeriodIdList",
    optionsRequest: getAllPaymentApi,
    optReqParams: { status: 1, pageNum: 1, pageSize: 9999999, total: 0 },
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data.records || [];
      }
    },
    optConfig: {
      label: "accountName",
      value: "id"
    },
    attrs: {
      mode: "multiple"
    },
    options: []
  }),
  {
    type: "datetimerange",
    label: "拣货时间",
    keyName: "depositTime"
  },
  {
    type: "select",
    label: "报关计费",
    keyName: "billingMethodList",
    optConfig: {
      label: "name",
      value: "code"
    },
    options: [
      {
        name: "单票计费",
        code: 1
      },
      {
        name: "合并计费",
        code: 2
      }
    ],
    attrs: {
      mode: "multiple"
    }
  }
];

export const tableColumnMap: Base.GeneraDataType<Array<SuperTable.TableCoulmnItem | SuperTable.NestTableColumnItem>> = {
  "1": [
    {
      type: "checkbox",
      field: "checkbox",
      minWidth: "50",
      fixed: "left"
    },
    {
      field: "customerName",
      title: "客户简称",
      minWidth: "120",
      fixed: "left"
    },
    {
      field: "waybillNum",
      title: "运单号",
      minWidth: "180",
      renderSlot: "waybillNum",
      fixed: "left"
    },
    {
      field: "fbaNumber",
      title: "FBA单号",
      minWidth: "160"
    },
    {
      field: "addressType",
      title: "运单类型",
      minWidth: "120",
      renderSlot: "addressType"
    },
    {
      field: "accountName",
      title: "账期",
      minWidth: "140"
    },
    {
      field: "channelName",
      title: "渠道",
      minWidth: "140"
    },
    {
      field: "itemNumber",
      title: "件数",
      minWidth: "80"
    },
    {
      field: "settlementWeight",
      title: "结算重",
      minWidth: "80"
    },
    {
      field: "squaresNumber",
      title: "方数",
      minWidth: "80"
    },
    {
      field: "actualWeight",
      title: "实重",
      minWidth: "80"
    },
    {
      field: "volumeWeight",
      title: "材积重",
      minWidth: "80"
    },
    {
      field: "billingMethod",
      title: "报关计费",
      minWidth: "100",
      renderSlot: "billingMethod"
    },
    {
      field: "bizName",
      title: "业务员",
      minWidth: "80"
    },
    {
      field: "companyName",
      title: "经营单位",
      minWidth: "80"
    },
    {
      field: "materialQualityName",
      title: "材质",
      minWidth: "120"
    },
    {
      field: "productName",
      title: "品名",
      minWidth: "80"
    },
    {
      field: "totalNormFreightPrice",
      title: "标准运费",
      minWidth: "80"
    },
    // {
    //   field: "totalAdjustPrice",
    //   title: "调整运费",
    //   minWidth: "80"
    // },
    // {
    //   field: "totalFreightPrice",
    //   title: "基础运费",
    //   minWidth: "80"
    // },
    {
      field: "totalAppendCostPrice",
      title: "附加费",
      minWidth: "80"
    },
    {
      field: "totalPrice",
      title: "总费用",
      minWidth: "80"
    },
    {
      field: "innerRemark",
      title: "内部备注",
      minWidth: "80"
    },
    {
      field: "remark",
      title: "客户备注",
      minWidth: "80"
    },
    {
      field: "depositTime",
      title: "拣货时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "action",
      title: "操作",
      minWidth: "90",
      renderSlot: "action",
      fixed: "right"
    }
  ],
  "2": [
    {
      type: "checkbox",
      field: "checkbox",
      minWidth: "50",
      fixed: "left"
    },
    {
      field: "customerName",
      title: "客户简称",
      minWidth: "120",
      fixed: "left"
    },
    {
      field: "waybillNum",
      title: "运单号",
      minWidth: "180",
      renderSlot: "waybillNum",
      fixed: "left"
    },
    {
      field: "fbaNumber",
      title: "FBA单号",
      minWidth: "160"
    },
    {
      field: "addressType",
      title: "运单类型",
      minWidth: "120",
      renderSlot: "addressType"
    },
    {
      field: "accountName",
      title: "账期",
      minWidth: "140"
    },
    {
      field: "channelName",
      title: "渠道",
      minWidth: "140"
    },
    {
      field: "itemNumber",
      title: "件数",
      minWidth: "80"
    },
    {
      field: "settlementWeight",
      title: "结算重",
      minWidth: "80"
    },
    {
      field: "squaresNumber",
      title: "方数",
      minWidth: "80"
    },
    {
      field: "actualWeight",
      title: "实重",
      minWidth: "80"
    },
    {
      field: "volumeWeight",
      title: "材积重",
      minWidth: "80"
    },
    {
      field: "billingMethod",
      title: "报关计费",
      minWidth: "100",
      renderSlot: "billingMethod"
    },
    {
      field: "bizName",
      title: "业务员",
      minWidth: "80"
    },
    {
      field: "companyName",
      title: "经营单位",
      minWidth: "80"
    },
    {
      field: "materialQualityName",
      title: "材质",
      minWidth: "120"
    },
    {
      field: "productName",
      title: "品名",
      minWidth: "80"
    },
    {
      field: "totalNormFreightPrice",
      title: "标准运费",
      minWidth: "80"
    },
    {
      field: "totalAdjustPrice",
      title: "调整运费",
      minWidth: "80"
    },
    {
      field: "totalFreightPrice",
      title: "基础运费",
      minWidth: "80"
    },
    {
      field: "totalAppendCostPrice",
      title: "附加费",
      minWidth: "80"
    },
    {
      field: "totalPrice",
      title: "总费用",
      minWidth: "80"
    },
    {
      field: "innerRemark",
      title: "内部备注",
      minWidth: "80"
    },
    {
      field: "remark",
      title: "客户备注",
      minWidth: "80"
    },
    {
      field: "depositTime",
      title: "拣货时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "action",
      title: "操作",
      minWidth: "70",
      renderSlot: "action",
      fixed: "right"
    }
  ],
  "3": [
    {
      type: "checkbox",
      field: "checkbox",
      minWidth: "50",
      fixed: "left"
    },
    {
      field: "customerName",
      title: "客户简称",
      minWidth: "120",
      fixed: "left"
    },
    {
      field: "waybillNum",
      title: "运单号",
      minWidth: "180",
      renderSlot: "waybillNum",
      fixed: "left"
    },
    {
      field: "fbaNumber",
      title: "FBA单号",
      minWidth: "160"
    },
    {
      field: "addressType",
      title: "运单类型",
      minWidth: "120",
      renderSlot: "addressType"
    },
    {
      field: "accountName",
      title: "账期",
      minWidth: "140"
    },
    {
      field: "channelName",
      title: "渠道",
      minWidth: "140"
    },
    {
      field: "itemNumber",
      title: "件数",
      minWidth: "80"
    },
    {
      field: "settlementWeight",
      title: "结算重",
      minWidth: "80"
    },
    {
      field: "squaresNumber",
      title: "方数",
      minWidth: "80"
    },
    {
      field: "actualWeight",
      title: "实重",
      minWidth: "80"
    },
    {
      field: "volumeWeight",
      title: "材积重",
      minWidth: "80"
    },
    {
      field: "billingMethod",
      title: "报关计费",
      minWidth: "100",
      renderSlot: "billingMethod"
    },
    {
      field: "bizName",
      title: "业务员",
      minWidth: "80"
    },
    {
      field: "companyName",
      title: "经营单位",
      minWidth: "80"
    },
    {
      field: "materialQualityName",
      title: "材质",
      minWidth: "120"
    },
    {
      field: "productName",
      title: "品名",
      minWidth: "80"
    },
    {
      field: "totalNormFreightPrice",
      title: "标准运费",
      minWidth: "80"
    },
    {
      field: "totalAdjustPrice",
      title: "调整运费",
      minWidth: "80"
    },
    {
      field: "totalFreightPrice",
      title: "基础运费",
      minWidth: "80"
    },
    {
      field: "totalAppendCostPrice",
      title: "附加费",
      minWidth: "80"
    },
    {
      field: "totalPrice",
      title: "总费用",
      minWidth: "80"
    },
    {
      field: "innerRemark",
      title: "内部备注",
      minWidth: "80"
    },
    {
      field: "remark",
      title: "客户备注",
      minWidth: "80"
    },
    {
      field: "depositTime",
      title: "拣货时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "action",
      title: "操作",
      minWidth: "210",
      renderSlot: "action",
      fixed: "right"
    }
  ],
  "4": [
    {
      type: "checkbox",
      field: "checkbox",
      minWidth: "50",
      fixed: "left"
    },
    {
      field: "customerName",
      title: "客户简称",
      minWidth: "120",
      fixed: "left"
    },
    {
      field: "waybillNum",
      title: "运单号",
      minWidth: "180",
      renderSlot: "waybillNum",
      fixed: "left"
    },
    {
      field: "fbaNumber",
      title: "FBA单号",
      minWidth: "160"
    },
    {
      field: "addressType",
      title: "运单类型",
      minWidth: "120",
      renderSlot: "addressType"
    },
    {
      field: "accountName",
      title: "账期",
      minWidth: "140"
    },
    {
      field: "channelName",
      title: "渠道",
      minWidth: "140"
    },
    {
      field: "itemNumber",
      title: "件数",
      minWidth: "80"
    },
    {
      field: "settlementWeight",
      title: "结算重",
      minWidth: "80"
    },
    {
      field: "squaresNumber",
      title: "方数",
      minWidth: "80"
    },
    {
      field: "actualWeight",
      title: "实重",
      minWidth: "80"
    },
    {
      field: "volumeWeight",
      title: "材积重",
      minWidth: "80"
    },
    {
      field: "billingMethod",
      title: "报关计费",
      minWidth: "100",
      renderSlot: "billingMethod"
    },
    {
      field: "bizName",
      title: "业务员",
      minWidth: "80"
    },
    {
      field: "companyName",
      title: "经营单位",
      minWidth: "80"
    },
    {
      field: "materialQualityName",
      title: "材质",
      minWidth: "120"
    },
    {
      field: "productName",
      title: "品名",
      minWidth: "80"
    },
    {
      field: "totalNormFreightPrice",
      title: "标准运费",
      minWidth: "80"
    },
    {
      field: "totalAdjustPrice",
      title: "调整运费",
      minWidth: "80"
    },
    {
      field: "totalFreightPrice",
      title: "基础运费",
      minWidth: "80"
    },
    {
      field: "totalAppendCostPrice",
      title: "附加费",
      minWidth: "80"
    },
    {
      field: "totalPrice",
      title: "总费用",
      minWidth: "80"
    },
    {
      field: "innerRemark",
      title: "内部备注",
      minWidth: "80"
    },
    {
      field: "remark",
      title: "客户备注",
      minWidth: "80"
    },
    {
      field: "depositTime",
      title: "拣货时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "action",
      title: "操作",
      minWidth: "160",
      renderSlot: "action",
      fixed: "right"
    }
  ],
  "5": [
    {
      type: "checkbox",
      field: "checkbox",
      minWidth: "50",
      fixed: "left"
    },
    {
      field: "customerName",
      title: "客户简称",
      minWidth: "120",
      fixed: "left"
    },
    {
      field: "waybillNum",
      title: "运单号",
      minWidth: "180",
      renderSlot: "waybillNum",
      fixed: "left"
    },
    {
      field: "fbaNumber",
      title: "FBA单号",
      minWidth: "160"
    },
    {
      field: "addressType",
      title: "运单类型",
      minWidth: "120",
      renderSlot: "addressType"
    },
    {
      field: "accountName",
      title: "账期",
      minWidth: "140"
    },
    {
      field: "channelName",
      title: "渠道",
      minWidth: "140"
    },
    {
      field: "itemNumber",
      title: "件数",
      minWidth: "80"
    },
    {
      field: "settlementWeight",
      title: "结算重",
      minWidth: "80"
    },
    {
      field: "squaresNumber",
      title: "方数",
      minWidth: "80"
    },
    {
      field: "actualWeight",
      title: "实重",
      minWidth: "80"
    },
    {
      field: "volumeWeight",
      title: "材积重",
      minWidth: "80"
    },
    {
      field: "billingMethod",
      title: "报关计费",
      minWidth: "100",
      renderSlot: "billingMethod"
    },
    {
      field: "bizName",
      title: "业务员",
      minWidth: "80"
    },
    {
      field: "companyName",
      title: "经营单位",
      minWidth: "80"
    },
    {
      field: "materialQualityName",
      title: "材质",
      minWidth: "120"
    },
    {
      field: "productName",
      title: "品名",
      minWidth: "80"
    },
    {
      field: "totalNormFreightPrice",
      title: "标准运费",
      minWidth: "80"
    },
    {
      field: "totalAdjustPrice",
      title: "调整运费",
      minWidth: "80"
    },
    {
      field: "totalFreightPrice",
      title: "基础运费",
      minWidth: "80"
    },
    {
      field: "totalAppendCostPrice",
      title: "附加费",
      minWidth: "80"
    },
    {
      field: "totalPrice",
      title: "总费用",
      minWidth: "80"
    },
    {
      field: "innerRemark",
      title: "内部备注",
      minWidth: "80"
    },
    {
      field: "remark",
      title: "客户备注",
      minWidth: "80"
    },
    {
      field: "depositTime",
      title: "拣货时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "action",
      title: "操作",
      minWidth: "130",
      renderSlot: "action",
      fixed: "right"
    }
  ]
};
